﻿#ifndef SECSENUM_H
#define SECSENUM_H

/*
 * 当前类涵盖了SECS协议中常用的枚举,并提供经静态方法来获取这些枚举的字符串
 */

#include <QObject>
#include <QMetaEnum>

class SecsEnum : public QObject
{
    Q_OBJECT
public:
    enum CommunicationState
    {
        NOT_ENABLED,

        NOT_COMMUNICATING,

        COMMUNICATING,
    };
    Q_ENUM(CommunicationState)

    enum ConnectionState
    {
        NOT_CONNECTED,

        NOT_SELECTED,

        SELECTED,
    };
    Q_ENUM(ConnectionState)

    enum ConnectMode
    {
        ACTIVE,

        PASSIVE,
    };
    Q_ENUM(ConnectMode)

    enum ControlState
    {
        EQUIPMENT_OFFLINE,

        ATTEMPT_ONLINE,

        HOST_OFFLINE,

        ONLINE_LOCAL,

        ONLINE_REMOTE,
    };
    Q_ENUM(ControlState)

    enum Formate
    {
        LIST = 0x00,

        BOOLEAN = 0x24,

        ASCII = 0x40,

        U1 = 0xa4,

        U2 = 0xa8,

        U4 = 0xb0,

        U8 = 0xa0,

        I1 = 0x64,

        I2 = 0x68,

        I4 = 0x70,

        I8 = 0x60,

        F4 = 0x90,

        F8 = 0x80,

        BINARY = 0x20,

        None = 0xff,
    };
    Q_ENUM(Formate)

    enum FormateLength
    {
        U1_LENGTH = 1,

        U2_LENGTH = 2,

        U4_LENGTH = 4,

        U8_LENGTH = 8,

        I1_LENGTH = 1,

        I2_LENGTH = 2,

        I4_LENGTH = 4,

        I8_LENGTH = 8,

        F4_LENGTH = 4,

        F8_LENGTH = 8,

        B_LENGTH = 1,

        C_LENGTH = 1,
    };
    Q_ENUM(FormateLength)

    enum PType
    {
        SECS_II = 0x00,

        UNKNOWN = 0xff,
    };
    Q_ENUM(PType)

    enum SType
    {
        DATA = 0x00,

        SELECT_REQ = 0x01,

        SELECT_RSP = 0x02,

        DESELECT_REQ = 0x03,

        DESELECT_RSP = 0x04,

        LINKTEST_REQ = 0x05,

        LINKTEST_RSP = 0x06,

        REJECT = 0x07,

        SEPARATE = 0x09,
    };
    Q_ENUM(SType)

    enum SelectStatus
    {
        CommunicationEstablished = 0x00,

        CommunicationAlreadyActive = 0x01,

        ConnectionNotReady = 0x02,

        ConnectExhaust = 0x03,

        OtherSelectStatus = 0x80,
    };
    Q_ENUM(SelectStatus)

    enum DeselectStatus
    {
        CommunicationEnded = 0x00,

        CommunicationNotEstablished = 0x01,

        CommunicationBusy = 0x02,

        OtherDeselectStatus = 0x80,
    };
    Q_ENUM(DeselectStatus)

    enum RejectReasonCode
    {
        STypeNotSupport = 0x01,

        PTypeNotSupport = 0x02,

        TransactionNotOpen = 0x03,

        EntityNotSelected = 0x04,

        OtherRejectReasonCode = 0x80,
    };
    Q_ENUM(RejectReasonCode)

    static QString getStrCommunicationState(CommunicationState communicationState);
    static QString getStrConnectionState(ConnectionState connectionState);
    static QString getStrConnectMode(ConnectMode connectMode);
    static QString getStrControlState(ControlState controlState);
    static QString getStrFormate(Formate formate);
    static QString getStrFormateLength(FormateLength formateLength);
    static QString getStrPType(PType pType);
    static QString getStrSType(SType sType);
    static QString getStrSelectStatus(SelectStatus selectStatus);
    static QString getStrDeselectStatus(DeselectStatus deselectStatus);
    static QString getRejectReasonCode(RejectReasonCode rejectReasonCode);
};

#endif // SECSENUM_H
